#include <bits/stdc++.h>
#define uint unsigned long long
#define sint long long
using namespace std;
int arr[25];
bool col[25];
sint dfs(int n, int pos = 0){
	if(pos == n){
		sint result = 0;
		for(int i = 0; i < n; i++){
			for(int j = i - 1; j >= 0; j--){
				if(col[i] == col[j]){
					if(arr[i] == arr[j]) result += arr[i];
					break;
				}
			}
		}
		return result;
	}
	col[pos] = false;
	const sint res1 = dfs(n, pos + 1);
	col[pos] = true;
	const sint res2 = dfs(n, pos + 1);
	col[pos] = false;
	return max(res1, res2);
}
int main()
{
	freopen("color.in", "r", stdin);
	freopen("color.out", "w", stdout);
	int t;
	scanf("%d", &t);
	for(int l = 0; l < t; l++){
		int n;
		scanf("%d", &n);
		for(int i = 0; i < n; i++){
			scanf("%d", &arr[i]);
		}
		printf("%lld\n", dfs(n));
	}
	
	return 0;
}